<%@ page contentType= "text/html;charset=gb2312" %>

<html>
<%@ include file="../common/base.jsp" %>
<body>

<div id="container">
	<%@ include file="../common/header.jsp" %>
	<div id="menu">
		<a href="<c:url value="/common/home.o"/>"><fmt:message key="Home" /></a> > 
	    <a href="<c:url value="/template/manage.o"/>"><fmt:message key="Template" /></a> >
	   <fmt:message key="${action}" />
	    <div  style="float: right" ><fmt:message key="Logged" />: <c:out value="${currentUser.username}" /> (<a href="<c:url value="/common/logout.o"/>"><fmt:message key="Logout" /></a>)</div>
	</div>
	
	<div id="midbody">
	      <div id="leftside">
		 	<br>
		   	<a href="<c:url value="/template/manage.o"/>"><fmt:message key="AllTemplate" /></a>
		   	<br><br>
		   	<a href="<c:url value="/template/create.o"/>"><fmt:message key="CreateTemplate" /></a>
	      </div>
	      <div id="rightside">
	    	   
	        <div id="bigbox">
		        <div class="title">
		        	<fmt:message key="${action}" /> <fmt:message key="Template" />
		        	<%@ include file="../common/hidemenu.jsp" %>
		        </div>
		        <div class="content">
	
		            <form:form modelAttribute="template">
		                <form:errors path="*" element="div" cssClass="errors"/>
		                <div><div class="form-label"><fmt:message key="Name" />:</div><form:input path="name"/></div>
		                <div><div class="form-label"><fmt:message key="Description" />:</div><form:textarea path="description"/></div>
		                <div><div class="form-label"><fmt:message key="Scope" />:</div>&nbsp;</div>
		                <div>
		                	<table>
		                		<tr>
		                			<td><form:checkbox path="steps" value="step10_1"/>step10_1</td>
		                			<td><form:checkbox path="steps" value="step10_2"/>step10_2</td>
		                			<td><form:checkbox path="steps" value="step20"/>step20</td>
		                			<td><form:checkbox path="steps" value="step30_1"/>step30_1</td>
		                		</tr>
		                		<tr>
		                			<td><form:checkbox path="steps" value="step30_2"/>step30_2</td>
		                			<td><form:checkbox path="steps" value="step40"/>step40</td>
		                			<td><form:checkbox path="steps" value="step50"/>step50</td>
		                			<td><form:checkbox path="steps" value="step60"/>step60</td>
		                		</tr>
		                		<tr>
		                			<td><form:checkbox path="steps" value="step70"/>step70</td>
		                			<td><form:checkbox path="steps" value="step80"/>step80</td>
		                			<td><form:checkbox path="steps" value="step90"/>step90</td>
		                			<td><form:checkbox path="steps" value="step100_1" onclick="chkstep100(this)"/>step100_1</td>
		                		</tr>
		                		<tr>
		                			<td><form:checkbox path="steps" value="step100_2" onclick="chkstep100(this)"/>step100_2</td>
		                			<td><form:checkbox path="steps" value="step100_3" onclick="chkstep100(this)"/>step100_3</td>
		                			<td><form:checkbox path="steps" value="step110"/>step110</td>
		                			<td><form:checkbox path="steps" value="step120_1" onclick="chkstep120(this)"/>step120_1</td>
		                		</tr>
		                		<tr>
		                			<td><form:checkbox path="steps" value="step120_2" onclick="chkstep120(this)"/>step120_2</td>
		                			<td><form:checkbox path="steps" value="step130"/>step130</td>
		                			<td><form:checkbox path="steps" value="step140_1"/>step140_1</td>
		                			<td><form:checkbox path="steps" value="step140_2"/>step140_2</td>
		                		</tr>
		                		<tr>
		                			<td><form:checkbox path="steps" value="step150"/>step150</td>
		                			<td><form:checkbox path="steps" value="step160"/>step160</td>
		                			<td><form:checkbox path="steps" value="step170_1"/>step170_1</td>
		                			<td><form:checkbox path="steps" value="step170_2"/>step170_2</td>
		                		</tr>
		                		<tr>
		                			<td><form:checkbox path="steps" value="step180"/>step180</td>
		                			<td></td>
		                			<td></td>
		                			<td></td>
		                		</tr>
		                	</table>
		                </div>
						
						<p><input id="cka" type="checkbox" onclick="chkall(this)" ><fmt:message key="SelectAll" /></p>
		                <div>
		                	<input type="submit" value="<fmt:message key='Save' />"/>&nbsp;
		                	<input type="button" onclick="document.location.href='<c:url value="/template/manage.o"/>'" value="<fmt:message key='Cancel' />"/>
		                </div>
		            </form:form>
		        </div>
	    	</div>
		</div>
	</div>
	<%@ include file="../common/foot.jsp" %>
</div>
	
<script type="text/javascript">
document.getElementById('name').focus();
init();

function init(){
    var input = document.getElementsByTagName("input");
    var objLen = input.length;
    var flag = true;
    for (var i = 0; i < objLen; i++){
    	if(input[i].id == "cka")
    		continue;
        if (input[i].type == "checkbox"){
           flag = flag && input[i].checked;
        }
    }
    input["cka"].checked = flag;
}

function chkall(ck){
    var input = document.getElementsByTagName("input");
    var objLen = input.length;
    for (var i = 0; i < objLen; i++){
        if (ck.checked == true){
            if (input[i].type == "checkbox"){
               input[i].checked = true;
            }
        }else {
            if (input[i].type == "checkbox") {
                input[i].checked = false;
            }
        }
    }
}

function chkstep100(ck){
    var input = document.getElementsByTagName("input");
    var objLen = input.length;
    for (var i = 0; i < objLen; i++){
        if (ck.checked == true){
            if (input[i].type == "checkbox" && (input[i].value == "step100_1" || input[i].value == "step100_2" || input[i].value == "step100_3")){
               input[i].checked = true;
            }
        }else {
            if (input[i].type == "checkbox" && (input[i].value == "step100_1" || input[i].value == "step100_2" || input[i].value == "step100_3")){
                input[i].checked = false;
            }
        }
    }
}

function chkstep120(ck){
    var input = document.getElementsByTagName("input");
    var objLen = input.length;
    for (var i = 0; i < objLen; i++){
        if (ck.checked == true){
            if (input[i].type == "checkbox" && (input[i].value == "step120_1" || input[i].value == "step120_2")){
               input[i].checked = true;
            }
        }else {
            if (input[i].type == "checkbox" && (input[i].value == "step120_1" || input[i].value == "step120_2")){
                input[i].checked = false;
            }
        }
    }
}
</script>

</body>
</html>
